package com.yanqu.road.server.manager.tomb.astar;

public class Coordinate {

    public static Coordinate newInstance(int x, int y) {
        Coordinate coordinate = new Coordinate();
        coordinate.setX(x);
        coordinate.setY(y);
        coordinate.setKey(String.format("%d_%d", x, y));
        return coordinate;
    }

    private int x;
    private int y;

    private String key;
    private int distance;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        Coordinate coordinate = (Coordinate) obj;
        return coordinate.getX() == this.x && coordinate.getY() == this.y;
    }
}
